﻿@{
    ViewBag.Title = "首页";
}
<div class="ui grid">
    <div class="three wide column">
        <div class="ui teal vertical menu">
            <a class="item">技术文章</a>
            <a class="item">热爱生活</a>
            <a class="item">坦克世界</a>
            <a class="item">骑光异彩</a>
            <a class="item">情侣笔记</a>
        </div>
    </div>
    <div class="thirteen wide column">
        <div class="ui breadcrumb">
            <a class="section">文章中心</a>
            <i class="right chevron icon divider"></i>
            <a class="section">坦克世界</a>
            <i class="right chevron icon divider"></i>
            <div class="active section">找个坦克来爱我</div>
        </div>
        <div class="ui tb">
            <table class="ui celled striped table">
                <thead>
                    <tr>
                        <th width="6%">序号</th>
                        <th>用户名</th>
                        <th>角色</th>
                        <th>创建时间</th>
                        <th width="12%">操作</th>
                    </tr>
                </thead>
                <tbody id="dataArea">
                    <tr>
                        <td colspan="5">正在加载 ...</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="ui divider"></div>
        <div class="page">
            <div class="ui pagination menu teal">
                <a class="icon item"><i class="left arrow icon"></i></a>
                <a class="active item">1</a>
                <div class="disabled item">...</div>
                <a class="item">10</a>
                <a class="item">11</a>
                <a class="item">12</a>
                <a class="icon item"><i class="right arrow icon"></i></a>
            </div>
        </div>
    </div>
</div>
<script>
    //初始化
    $(function () {
        //业务测试
        bindData({
            index: page,
            url: "/home/getuser",
            data: {},
            before: function () {
                qibu.msgbox.loading("加载中...");
            },
            success: function (data) {
                qibu.msgbox.hide();
                if (data.length > 0) {
                    createHtml(data);
                }
            }
        });
    });
    //构建DOM
    function createHtml(list) {
        var contents = "";
        var arrHtml = [];
        $.each(list, function (i, item) {
            arrHtml.push('<tr id="rc_' + item.Id + '">');
            arrHtml.push('    <td>' + (size * (page - 1) + (i + 1)) + '</td>');
            arrHtml.push('    <td>' + item.UserName + '</td>');
            arrHtml.push('    <td>' + item.UserType + '</td>');
            arrHtml.push('    <td>' + JsonDateHelper.getDateTime(item.CreateTime) + '</td>');
            arrHtml.push('    <td>');
            arrHtml.push('        <a class="" href="javascript:;">编辑</a><span>&nbsp;|&nbsp;</span>');
            arrHtml.push('        <a class="" href="javascript:deleteRecord(' + item.Id + ',\'' + item.UserName + '\');">删除</a>');
            arrHtml.push('    </td>');
            arrHtml.push('</tr>');
        });
        $("#dataArea").html(arrHtml.join(''));
    }
</script>